﻿Public Class formipkill

    Private Sub btnkill_Click(sender As Object, e As EventArgs) Handles btnkill.Click
        Dim resultkill As String
        Dim namekill As String

        Dim ipkill As String
        ipkill = textipkill.Text
        namekill = textnamekill.Text

        lbnerror.Text = ""


        If textnamekill.Text = "" Then
            MsgBox("Please inser name Processs to kill", MsgBoxStyle.Exclamation)
            Return


        End If

        If textipkill.Text = "" Then

            Dim NewProcess As New System.Diagnostics.Process()
            With NewProcess.StartInfo
                .FileName = "c:\windows\pskill.exe"
                .Arguments = "-t" & " " & namekill
                .RedirectStandardOutput = True
                .RedirectStandardError = True
                .RedirectStandardInput = True
                .UseShellExecute = False
                .WindowStyle = ProcessWindowStyle.Normal
                .CreateNoWindow = True
            End With

            NewProcess.Start()

            System.Threading.Thread.Sleep(2000)
            resultkill = NewProcess.StandardOutput.ReadToEnd
            richtextkill.Text = resultkill

            textnamekill.Clear()
            Return

        End If

        If textipkill.Text = "" Then
            MsgBox("Please Insert IP Address", MsgBoxStyle.Exclamation)
            Return

        End If

        If My.Computer.Network.Ping(ipkill) = True Then

            richtextkill.Text = ""

            Dim NewProcess As New System.Diagnostics.Process()
            With NewProcess.StartInfo
                .FileName = "c:\windows\pskill.exe"
                .Arguments = "-t" & " " & "\\" & ipkill & " " & namekill
                .RedirectStandardOutput = True
                .RedirectStandardError = True
                .RedirectStandardInput = True
                .UseShellExecute = False
                .WindowStyle = ProcessWindowStyle.Normal
                .CreateNoWindow = True
            End With

            NewProcess.Start()

            System.Threading.Thread.Sleep(2000)
            resultkill = NewProcess.StandardOutput.ReadToEnd
            richtextkill.Text = resultkill

        Else
            lbnerror.Text = "IP Address Is shutdown or incorrect "
        End If

        textipkill.Clear()
        textnamekill.Clear()



    End Sub

    Private Sub formipkill_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Close()

    End Sub

    Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click

    End Sub

    Private Sub lbnipkill_Click(sender As Object, e As EventArgs) Handles lbnipkill.Click

    End Sub
End Class